package pluggy.core;

import java.net.URL;
import java.net.URLClassLoader;
import java.util.ServiceLoader;

import pluggy.plugins.Plugin;

public class Pluggy {
	public static void main(String[] args) {
		//Get the System Classloader
        ClassLoader sysClassLoader = ClassLoader.getSystemClassLoader();

        //Get the URLs
        URL[] urls = ((URLClassLoader)sysClassLoader).getURLs();

        for(int i=0; i< urls.length; i++)
        {
            System.out.println(urls[i].getFile());
        }       
		
		System.out.println("pluggy started");
		
		System.out.println("loading plugins");
		ServiceLoader<Plugin> plugins = ServiceLoader.load(Plugin.class);
		
		System.out.println("initing plugins");
		for (Plugin plugin : plugins)
			plugin.init();
		
		System.out.println("starting plugins");
		for (Plugin plugin : plugins)
			plugin.run();
		
	}
}
